// 该文件是专门用于创建整个应用的路由器

// 第一步引入插件(本质是一个构造函数)
import VueRouter from "vue-router";

// 引入一下用到的组件
// import Manuscripts from "../components/Manager/AuditManuscripts";
// import BlackList from "../components/Manager/BlackList";
// import UserList from "../components/Manager/UserList";
//import CollectInfo from "../components/UserInfo/CollectInfo";
//import LearningInfo from "../components/UserInfo/LearningInfo";
//import Overview from "../components/UserInfo/Overview";
//import PublishInfo from "../components/UserInfo/PublishInfo";
//import AboutUs from "../pages/AboutUs";
//import EditUser from "../pages/EditUserPage";
//import Home from "../pages/HomePage";
//import Login from "../pages/LoginPage";
//import Manager from "../pages/ManagerPage";
//import Register from "../pages/RegisterPage";
//import RouteEditor from "../pages/RouteEditorPage";
//import Route from "../pages/RoutePage";
//import Search from "../pages/SearchPage";
//import SearchRoutes from "../pages/SearchRouter/RouteResult";
//import SearchUsers from "../pages/SearchRouter/UserResult";
//import User from "../pages/UserPage";

//import NotFound from "../pages/404Page";

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch((err) => err);
};
// 第二步创建router实例对象并暴露
export default new VueRouter({
	routes: [
		{
			// path是路径
			path: "/",
			//跳转的组件
			component: () => import("../pages/HomePage"),
		},
		{
			path: "/login",
			component: () => import("../pages/LoginPage"),
		},
		{
			path: "/register",
			component: () => import("../pages/RegisterPage"),
		},
		{
			name: "search",
			path: "/search",
			component: () => import("../pages/SearchPage"),
			children: [
				{
					name: "searchRoutes",
					path: "routes",
					component: () => import("../pages/SearchRouter/RouteResult"),
				},
				{
					path: "users",
					component: () => import("../pages/SearchRouter/UserResult"),
				},
			],
		},
		{
			path: "/user",
			component: () => import("../pages/UserPage"),
			children: [
				{
					path: "/",
					component: () => import("../components/UserInfo/Overview"),
				},
				{
					path: "learninginfo",
					component: () => import("../components/UserInfo/LearningInfo"),
				},
				{
					path: "publishinfo",
					component: () => import("../components/UserInfo/PublishInfo"),
				},
				{
					path: "collectinfo",
					component: () => import("../components/UserInfo/CollectInfo"),
				},
			],
		},
		{
			path: "/edit",
			component: () => import("../pages/EditUserPage"),
		},
		{
			path: "/route",
			component: () => import("../pages/RoutePage"),
		},
		{
			path: "/manager",
			component: () => import("../pages/ManagerPage"),
			// children: [
			// 	{
			// 		path: "/",
			// 		component: Manuscripts,
			// 	},
			// 	{
			// 		path: "manuscripts",
			// 		component: Manuscripts,
			// 	},
			// 	{
			// 		path: "userlist",
			// 		component: UserList,
			// 	},
			// 	{
			// 		path: "blacklist",
			// 		component: BlackList,
			// 	},
			// ],
		},
		{
			path: "/editor",
			component: () => import("../pages/RouteEditorPage"),
		},
		{
			path: "/about",
			component: () => import("../pages/AboutUs"),
		},
		{
			path: "/404",
			component: () => import("../pages/404Page"),
		},
		{
			path: "*",
			redirect: "/404",
		},
	],
});
// 然后去main.js中引入router实例
